<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>一个多用户博客后台</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico"> <link href="../public/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="../public/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.13.1/bootstrap-table.min.css">
    <link href="../public/css/animate.css" rel="stylesheet">
    <link href="../public/css/style.css?v=4.1.0" rel="stylesheet">
    

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
       

        <!-- Panel Other -->
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>所有文章</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                        <i class="fa fa-wrench"></i>
                    </a>
                    <ul class="dropdown-menu dropdown-user">
                        <li><a href="#">选项1</a>
                        </li>
                        <li><a href="#">选项2</a>
                        </li>
                    </ul>
                    <a class="close-link">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <div class="row row-lg">
                    <div class="col-sm-12">
                        <!-- Example Events -->
                        <div class="example-wrap">
                            <div class="example">
                                <div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group">
                                    <button type="button" class="btn btn-outline btn-default">
                                        <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>
                                    </button>
                                    <button type="button" class="btn btn-outline btn-default" onclick="getSelectRow()">
                                        <i class="glyphicon glyphicon-heart" aria-hidden="true"></i>
                                    </button>
                                    <button type="button" class="btn btn-outline btn-default">
                                        <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
                                    </button>
                                </div>
                                <table id="cnm" data-height="550" data-mobile-responsive="true">
                                    <thead>
                                        <tr>
                                            <th data-field="xuhao" data-formatter="xuhao">序号</th>
                                            <th data-field="_id">ID</th>
                                            <th data-field="categoryId.name">分类</th>
                                            <th data-field="authorId.name">作者</th>
                                            <th data-field="title">标题</th>
                                            <th data-field="createAt">日期</th>
                                            <th data-field="countInfo.commentCount">评论</th>
                                            <th data-field="top" data-formatter="zhiding">置顶</th>
                                            <th data-field="good" data-formatter="jinghua">精华</th>
                                            <th data-field="state" data-formatter="zhuantai">状态</th>
                                            <th data-formatter="actionFormatter" data-align="center">操作</th>
                                        </tr>
                                    </thead>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
     
    <!-- 全局js -->
    <script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <!-- 自定义js -->
    <script src="../public/js/content.js?v=1.0.0"></script>


    <!-- Bootstrap table -->
    <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.13.1/bootstrap-table.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.13.1/locale/bootstrap-table-zh-CN.min.js"></script>

    <!-- Peity -->
    <script>


        function EditViewById(id,tit){
            var url = '/admin/edit-acticle'+id
            var num = parseInt(Math.random()*100)
            var index = 100+ num
            console.log(tit)
            var name = tit.substring(0,8) + '...'
            window.parent.openNew(url,index,name)
        }
      
        function getSelectRow(){
            console.log($("#exampleTableEvents").bootstrapTable('getSelections'))
        }
            //操作栏的格式化
        function actionFormatter(value, row, index) {
            var result = "";
            result += "<a href='javascript:;' class='btn btn-xs blue' onclick=\"EditViewById('" + row._id + "','"+row.title+"')\" title='编辑'><span class='glyphicon glyphicon-pencil'></span></a>";
            result += "<a href='/admin/deletearc"+row._id+"' class='btn btn-xs red'  title='删除' target='_self'><span class='glyphicon glyphicon-remove'></span></a>";
            return result;
        }
        function jinghua(str){
      if(str){
        return 'GOOD'
      }else{
        return ''
      }
    }
    function zhiding(str){
      if(str){
        return 'TOP'
      }else{
        return ''
      }
    }
    function zhuantai(str){
      if(str){
        return '公开'
      }else{
        return '不公开'
      }
    }
      $('#cnm').bootstrapTable({
      url: "/admin/getArticleList",
      method: 'get',
      search: true,
      cache: false,      
      contentType: "application/x-www-form-urlencoded; charset=UTF-8",
      pagination: true,
      showRefresh: true,
      showColumns: true,
      iconSize: 'outline',
      toolbar: '#exampleTableEventsToolbar',
      icons: {
        refresh: 'glyphicon-repeat',
        columns: 'glyphicon-list'
      }
    });
    $('#cnm').bootstrapTable('hideColumn', '_id'); //隐藏_id
   function xuhao(value,row,index){  
          var pageNumber = $('#cnm').bootstrapTable('getOptions').pageNumber;  
          var pageSize = $('#cnm').bootstrapTable('getOptions').pageSize;  
          return (pageNumber-1) * pageSize+index+1;  
      }  
    </script>


</body>

</html>
